package bean;

import java.applet.Applet;
import java.awt.Label;
import java.util.Calendar;

public class Cronometro extends Applet implements Runnable {

private static final long serialVersionUID = 1L;
private Label etiqueta;
private long tiempoInicial = 0;
private Thread hilo;

public Label getEtiqueta() {
	return etiqueta;
}

public void init()
{
	etiqueta = new Label();
	add( etiqueta );
	tiempoInicial = System.currentTimeMillis();
	hilo = new Thread( this );
	hilo.start();	
}

@SuppressWarnings("deprecation")
public void fin(){
	hilo.stop();
}

public void run() {

	Calendar tiempo = Calendar.getInstance();
	
	while (true) {
		
		tiempo.setTimeInMillis( System.currentTimeMillis() - tiempoInicial );
		etiqueta.setText(
		tiempo.get( Calendar.MINUTE ) +
		":" +
		tiempo.get( Calendar.SECOND ) +
		":" +
		tiempo.get( Calendar.MILLISECOND )
		);
	}
}




}